<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="format-detection" content="telephone=no" />
    <script src="static/js/ydui.flexible.js"></script>
    <script src="static/js/jweixin-1.0.0.js"></script>

    <title>测试</title>
  </head>
  <body>
    <div id="app"></div>
    <script src="static/js/axios.min.js"></script>
    <script>
        var url_api="/web"
        //var appId = "wx00ad33c24e13448f"
        var appId = "wx9e6e9352b8503aeb"
        var code = GetQueryString("code")==null?"12313213":GetQueryString("code");
        console.log(appId)
        function GetQueryString(name){
            console.log(window.location)
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        }
        getLocations();     
        function getLocations(){
          var data;
          var uuu = location.href.split('#')[0];
		      let this_ = this;
          axios({
              method:'get',
              url: '/api/libiary/Jssdk',
              params:{
                appId:appId,
                url:uuu
              },
              withCredentials:true
          })
          .then(function (res) {  
              console.log(res)                             
              var temp = res.data.data
              wx.config({
                  debug: false, //开启调试模式
                  appId: temp.appid, // 必填，公众号的唯一标识
                  timestamp:temp.timestamp, // 必填，生成签名的时间戳
                  nonceStr: temp.nonceStr, // 必填，生成签名的随机串
                  signature: temp.signature,// 必填，签名
                  jsApiList: ['checkJsApi','chooseImage','scanQRCode'] //必填，需要使用的JS接口列表
              })
              wx.checkJsApi({
                  jsApiList: ['chooseImage','scanQRCode'],
                  success: function (res) {
                      if (res.checkResult.getLocation == false) {
                          alert('你的微信版本太低，不支持微信JS接口，请升级到最新的微信版本！');
                          return;
                      }else{
                          console.log('checkJsApi!!!!!')
                          console.log(res)
                      }
                  }
              });
              wx.error(function(res){ 
                  console.log('error')
                  console.log(res)
              });
          })
          .catch(function (error) {
              console.log(error);
              this.$Message.error('系统错误，请稍后再试'); 
          });
			
        }
    </script>
  </body>
</html>
